package com.chushouya.controller.order.admin;


import com.chushouya.common.constant.ServiceType;
import com.chushouya.common.support.Contexts;
import com.general.framework.core.schema.PageResult;
import com.general.framework.core.schema.Response;
import com.chushouya.order.dto.admin.order.OrderDataDTO;
import com.chushouya.order.dto.admin.order.OrderListDTO;
import com.chushouya.order.dto.admin.order.OrderQuery;
import com.chushouya.order.service.admin.AdminOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@Slf4j
@Api(tags = ServiceType.PLATFORM + "平台合作商订单管理")
@RestController
@RequestMapping(ServiceType.PLATFORM + "/partnerOrder")
public class PartnerOrderController {

    @Resource
    private AdminOrderService adminOrderService;

    @ApiOperation("获取订单列表接口")
    @GetMapping("/list")
    public Response<PageResult<OrderListDTO>> list(OrderQuery query) {
        query.setPartnerId(Contexts.getUserContext().getPartnerId());
        return Response.success(adminOrderService.selectOrderList(query));
    }
    
    @ApiOperation("获取订单详细接口")
    @GetMapping("/detail")
    public Response<OrderDataDTO> orderDetail(Long orderId) {
        final Long partnerId = Contexts.getUserContext().getPartnerId();
        return Response.success(adminOrderService.selectPartnerOrderDetail(orderId,partnerId));
    }



}
